package ge.zuraba.android.geofines.activities;

import ge.zuraba.android.geofines.R;
import ge.zuraba.android.geofines.adapters.FinesAdapter;

import java.util.ArrayList;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.ListView;

public class FineDetailActivity extends ListActivity {
	ListView detailList;
	private FinesAdapter adapter;
	LayoutInflater inflater;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.finedetail);

		detailList = (ListView) findViewById(R.id.listView1);
		inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		final String[] colNames = new String[] {
				"ქვითრის სერია/ავტომობილის ნომერი:", "გვარი სახელი:",
				"თარიღი:", "მუხლი:", "თანხა:", "მდგომარეობა:" };
		savedInstanceState = this.getIntent().getExtras();
		Document doc = Jsoup.parse(savedInstanceState.getString("rowElement"));
		Elements elements = doc.select(".col");

		ArrayList<String> colStrings = new ArrayList<String>();

		for (Element el : elements) {
			if (el.text().equals("")) {
				continue;
			}
			colStrings.add(el.text());
		}

		adapter = new FinesAdapter(this, R.layout.finedetail, colStrings,
				colNames);
		setListAdapter(adapter);
	}
}